//供其他页面调用声明
function __g_reloadData(){
	$(".datagrid:visible .tablex").datagrid("reload");
}


function edit(event){
	var url = $(this).data("url");
	__tabOpen(url,"修改模板");
	event.stopPropagation();
};


function before(){
	top.__g_iframeHeigthAsMain(window.name);
}

function init(){
	$('#table0').datagrid({
		"url" : "quick_backend/entityExample/query",
		"toolbar": [{
			iconCls: 'fa fa-plus',
			text:"增加",
			handler: function(){
				top.__g_getTabset().tabset("addShow",{src:"quick_backend/entityExample/add",title:"新增模板",openerId:window.name});
			}
		},'-',{
			iconCls: 'fa fa-recycle',
			text:"删除",
			handler: function(){
				var ids = $('#table0').datagrid("getCheckedIds");
				if($.isEmptyObject(ids)){
					$.messagebox.toast("请选择需要删除的记录","warning");
					return;
				}
				$.messagebox.confirm("是否删除记录",function(yes){
					if(yes){
						$.messagebox.waiting("删除中");
						$.post("quick_backend/entityExample/delete",$.param({"ids":ids},true),function(res){
							$.messagebox.waitingClose();
							if(res.success){
								$.messagebox.toast("删除成功","success");
								$('#table0').datagrid("reload");
							}else{
								$.messagebox.toast("删除失败:"+res.returnMessage,"danger");
							}
						},"json").error(function(){
							$.messagebox.waitingClose();
							alert("系统错误");
						});
					};
				});
			}
		}],
		"columns" : [ [ {
			field : 'ck',
			checkbox : true
		},{
			field : 'name',
			title : '<center><b>姓名</b></center>',
			width : 100,
			align : 'left',
			formatter : function(val,row,index){
				var domTmp = "<a class='edit' href='javascript:void(0);' onclick='edit.apply(this,arguments)' data-url='quick_backend/entityExample/edit?id={0}' >{1}</a>";
				return $.validator.format(domTmp,row.id,row.name);
			}
		}] ],

	}).datagrid('getPager').pagination();

    $(window).resize(function() {
		var $table = $(".datagrid:visible .tablex")
		$table.datagrid("resize",{
			width: $table.datagrid("getDefaultWidth"),
			height: $table.datagrid("getDefaultHeight")
    	});
    });

}

function after(){
	
}